from django.db import models
from .base import BaseModel

class BattleLog(BaseModel):
    """战斗日志模型"""
    battle = models.ForeignKey(
        'Battle',
        on_delete=models.CASCADE,
        related_name='logs',
        verbose_name='所属战斗'
    )
    action = models.ForeignKey(
        'Action',
        null=True,
        blank=True,
        on_delete=models.SET_NULL,
        related_name='logs',
        verbose_name='相关动作'
    )
    
    # 日志类型
    LOG_TYPES = [
        ('action', '动作'),
        ('effect', '效果'),
        ('state_change', '状态变化'),
        ('system', '系统'),
    ]
    log_type = models.CharField(
        max_length=20,
        choices=LOG_TYPES,
        verbose_name='日志类型'
    )
    
    round_number = models.IntegerField(verbose_name='回合数')
    content = models.TextField(verbose_name='日志内容')
    details = models.JSONField(default=dict, verbose_name='详细信息')
    
    class Meta:
        verbose_name = '战斗日志'
        verbose_name_plural = '战斗日志'
        ordering = ['created_at'] 